﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DotNetMigrations.Commands
{
	[ConsoleCommand("version")]
	public class VersionCmd : ConsoleCommand
	{
		public VersionCmd(string[] args) : base(args) { }

		public override bool ValidateArgs()
		{
			if (ArgCount < 1)
			{
				Output.Warn("Connection string not found");
				return false;
			}

			DAL.ConnectionString = ArgFetcher.GetConnectionString(Args);
			return true;
		}

		public override bool Run()
		{
			long currentVersion = SchemaInfoTable.GetSchemaVersion();
			long latestVersion = MigrationScript.GetLatestMigrationVersion();

			Output.Write("Database at version " + currentVersion);
			Output.Write("Migrations at version " + latestVersion);

			return true;
		}
	}
}
